home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / CD32 / CD32_Support / examples / SA_Examples / cd / CDTest / Data.cd < prev    next >
Encoding:
Text File  |  1993-08-31  |  13.1 KB  |  462 lines

  1. /* CD.DEVICE TEST (DATA) */
  2.  
  3. /**************************************************************************
  4.  *                                                                        *
  5.  * This script has been written to test the cd.device on the Amiga CD-32  *
  6.  *                                                                        *
  7.  * Its purpose is to test the cd.device as it relates to reading data.    *
  8.  *  Please use Audio.cd to test audio related commands.                   *
  9.  *                                                                        *
  10.  * Author:  Michael McLaughlin (mikemc@hydrogen)  [Drexel Co-op student]  *
  11.  *                                                                        *
  12.  **************************************************************************/
  13.  
  14. /* Constants */
  15. framesPerSec = 75   /* Frames per second */
  16.  
  17. Address CD.1           /* Reference to cd.device test program */
  18. OPTIONS RESULTS        /* Allow results */
  19.  
  20. say
  21. INFO initial                    /* Makes sure this doesn't run w/o a disk */
  22. if initial.Spin = 0 then do;
  23.   say 'Please insert disk before beginning the CD.DEVICE test.'
  24.   say
  25.   exit
  26. end;
  27.  
  28. /* NOTE:  Use the FILEPOS on floppy disk, NOT the CD.
  29.  
  30. The one that returns File CD0:PATTERN/OFFSET at block 3526 ($00000DC6)
  31.  is the wrong one.  It has been updated to return only the numeric value  */
  32.  
  33. Address command 'rxset' 'value' '`SYS:TEST/CD.DEVICE/FILEPOS CDTest3b:Tests/PATTERN/OFFSET`'
  34. /* Address command 'rxset' 'value' '`DF0:FILEPOS CDTest3b:Tests/PATTERN/OFFSET`' */
  35. offSet = strip(GetClip('value'))
  36. offSet = offSet * 512                          /* Convert blocks to bytes */
  37.  
  38. Address CD.1
  39.  
  40. say
  41.  
  42. /**************************************************************************/
  43.  
  44. say 'Enter the Read test? (y n a q ?)'
  45. pull goOn
  46. if goOn = ? then do;
  47.   say
  48.   say ' y = Yes'
  49.   say ' n = No'
  50.   say ' a = All tests'
  51.   say ' q = Quit this script'
  52.   say
  53.   pull goOn
  54. end;
  55. if ~((goOn ~= Y) | (goOn = Q)) | (goOn = A) then do;
  56.  
  57. /* Read */
  58. say
  59. say '-- Read test --'
  60. say
  61.  
  62. say 'Reading and verifying 2048 bytes of data.'
  63. READ offSet (2 * 1024) OV START 0                 /* Read and verify data */
  64.  
  65. say 'Reading and verifying 32 KB of data.'
  66. READ offSet (32 * 1024) OV START 0
  67.  
  68. say 'Reading and verifying 512 KB of data.'
  69. READ offSet (512 * 1024) OV START 0
  70.  
  71. say 'Reading and verifying 2 bytes of data.'
  72. READ offSet 2 OV START 0
  73.  
  74. say 'Reading and verifying 2046 bytes of data.'
  75. READ offSet 2046 OV START 0
  76.  
  77. say 'Reading and verifying 2050 bytes of data.'
  78. READ offSet 2050 OV START 0
  79.  
  80. say 'Reading and verifying the entire 16 MB file in 512 KB chunks.'
  81. tOffSet = offSet
  82. do i = 1 to ((16 * 1024 * 1024) % (512 * 1024))
  83.   READ tOffSet (512 * 1024) OV START 0         /* Read 512K block of data */
  84.   tOffSet = tOffSet + (512 * 1024)        /* Advance starting pos by 512K */
  85. end
  86. say
  87.  
  88. end;
  89.  
  90. /**************************************************************************/
  91.  
  92. if (goOn ~= Q) & (goOn ~= A) then do
  93.   say 'Enter the Read Speed test? (y n q)'
  94.   pull goOn
  95. end
  96. if ~((goOn ~= Y) | (goOn = Q)) | (goOn = A) then do;
  97.  
  98. /* Read Speed */
  99. say
  100. say '-- Read Speed test --'
  101. say
  102.  
  103. INFO thisDisk
  104. currFPS = thisDisk.ReadSpeed                  /* Stores current readspeed */
  105. call rSpeed                              /* Outputs the current readspeed */
  106.  
  107. say 'Changing data read speed to 150 Frames/Sec.'
  108. CONFIG READSPEED 150               /* Changes ReadSpeed to 150 Frames/Sec */
  109. call rSpeed
  110.  
  111. say 'Reading and verifying 512 KB of data.'
  112. READ offSet (512 * 1024) OV START 0
  113.  
  114. say
  115. say 'Changing data read speed back to the original' currFPS 'Frames/Sec.'
  116. CONFIG READSPEED currFPS
  117. call rSpeed
  118.  
  119. say 'Reading and verifying 512 KB of data.'
  120. READ offSet (512 * 1024) OV START 0
  121. say
  122.  
  123. end;
  124.  
  125. /**************************************************************************/
  126.  
  127. if (goOn ~= Q) & (goOn ~= A) then do
  128.   say 'Enter the Drive Geometry test? (y n q)'
  129.   pull goOn
  130. end
  131. if ~((goOn ~= Y) | (goOn = Q)) | (goOn = A) then do;
  132.  
  133. /* Drive Geometry */
  134. say
  135. say '-- Drive Geometry test --'
  136. say
  137.  
  138. GETGEOMETRY thisDisk
  139.  
  140. say 'Sector size         ' thisDisk.SectorSize 'bytes'
  141. say 'Total sectors       ' thisDisk.TotalSectors
  142. say 'Cylinder count      ' thisDisk.Cylinders
  143. say 'Sectors per Cylinder' thisDisk.CylSectors
  144. say 'Head count          ' thisDisk.Heads
  145. say 'Sectors per track   ' thisDisk.TrackSectors
  146. say 'Buffer memory type  ' thisDisk.BufMemType
  147. say 'Device type code    ' thisDisk.DeviceType
  148. say
  149.  
  150. if thisDisk.Removable = 0 then say 'This disk is non-removable.'
  151.   else say 'This disk is removable.'
  152. say
  153.  
  154. end;
  155.  
  156. /**************************************************************************/
  157.  
  158. if (goOn ~= Q) & (goOn ~= A) then do
  159.   say 'Enter the CD-ROM Recognition test? (y n q)'
  160.   pull goOn
  161. end
  162. if ~((goOn ~= Y) | (goOn = Q)) | (goOn = A) then do;
  163.  
  164. /* CD-ROM Recognition */
  165. say
  166. say '-- CD-ROM Recognition test --'
  167. say
  168.  
  169. INFO thisDisk                    /* Verify that a CD-ROM disc is inserted */
  170. if thisDisk.CDROM = 0 then do
  171.   say 'Please insert a CD-ROM disc for this test. (CR to cont.)'
  172.   call diskSwap                  /* Calls procedure to provoke a diskswap */
  173. end
  174.  
  175. call dInfo                              /* Reports disc/drive information */
  176.  
  177. say 'Please insert a mixed-mode disc (CD-DA and CD-ROM). (CR to cont.)'
  178. call diskSwap
  179.  
  180. call dInfo
  181.  
  182. say 'Please insert a digital audio disc (CD-DA). (CR to cont.)'
  183. call diskSwap
  184.  
  185. call dInfo
  186.  
  187. say 'Please re-insert the CD-ROM disc for future tests. (CR to cont.)'
  188. call diskSwap
  189. say
  190.  
  191. end;
  192.  
  193. /**************************************************************************/
  194.  
  195. if (goOn ~= Q) & (goOn ~= A) then do
  196.   say 'Enter the Protection Status test? (y n q)'
  197.   pull goOn
  198. end
  199. if ~((goOn ~= Y) | (goOn = Q)) | (goOn = A) then do;
  200.  
  201. /* Protection Status */
  202. say
  203. say '-- Protection Status test --'
  204. say
  205.  
  206. if PROSTATUS = 0 then say 'Disc is indeed writable.'
  207.   else say 'Disc is write-protected.'
  208. say
  209.  
  210. if (goOn = A) then call delay(3)  /* Allows disc to be recognized for the */
  211. say                               /* next test in the "All-Tests" status  */
  212.  
  213. end;
  214.  
  215. /**************************************************************************/
  216.  
  217. if (goOn ~= Q) & (goOn ~= A) then do
  218.   say 'Enter the Audio Commands during I/O test? (y n q)'
  219.   pull goOn
  220. end
  221. if ~((goOn ~= Y) | (goOn = Q)) | (goOn = A) then do;
  222.  
  223. /* Audio commands during I/O */
  224. say
  225. say '-- Audio commands during I/O test --'
  226. say
  227.  
  228. /*
  229. say 'Please insert the mixed-mode disc (CD-DA and CD-ROM). (CR to cont.)'
  230. call diskSwap
  231. */
  232.  
  233. TOCLSN lTOC 100 0            /* Pulls the Table of Contents in LSN format */
  234.  
  235. Address command 'run rx DataPlay.rexx' offSet
  236. Address CD.1
  237.  
  238. call delay(5)                                  /* Delay until read begins */
  239. say
  240.  
  241. say 'Attempting to attenuate.'
  242. ATTENUATE 375 0                            /* Effectively mutes the audio */
  243. ATTENUATE 0 32767                          /* Bring back to "full volume" */
  244.  
  245. segTime = 20 * framesPerSec
  246.  
  247. say 'Attempting to play' (segTime % framesPerSec) 'second segment of disc.'
  248. PLAYLSN lTOC.7.Position segTime
  249.  
  250. say 'Attempting to enter fast-forward mode.'
  251. SEARCH FFWD                        /* Attempts to engage in Fast-FWD mode */
  252.  
  253. say 'Attempting to enter fast-reverse mode.'
  254. SEARCH FREV                        /* Attempts to engage in Fast-REV mode */
  255.  
  256. say 'Attempting to return to normal speed mode.'
  257. SEARCH NORMAL                 /* Attempts to re-engage in the normal mode */
  258.  
  259. say 'Attempting to pause disc play for 5 seconds.'
  260. PAUSE ON                              /* Attempts to engage pause feature */
  261. call delay(5)
  262. PAUSE OFF                         /* Attempts to dis-engage pause feature */
  263.  
  264. say 'Attempting to kill motor for 5 seconds.'
  265. MOTOR OFF                             /* Attempts to dis-engage the motor */
  266. call delay(5)
  267. MOTOR ON                               /* Attempts to re-engage the motor */
  268. call delay(2)
  269.  
  270. segTime = 30 * framesPerSec
  271.  
  272. pTrack = random(3, lTOC.Summary.LastTrack, right(time('S'),2))
  273. say 'Attempting to play 30 sec. segment of randomly selected track' pTrack
  274. PLAYLSN lTOC.pTrack.Position segTime
  275. PLAYTRACK pTrack 1
  276. say
  277.  
  278. end;
  279.  
  280. /**************************************************************************/
  281.  
  282. if (goOn ~= Q) & (goOn ~= A) then do
  283.   say 'Enter the TOC test? (y n q)'
  284.   pull goOn
  285. end
  286. if ~((goOn ~= Y) | (goOn = Q)) | (goOn = A) then do;
  287.  
  288. say
  289. INFO thisDisk
  290. if thisDisk.CDROM = 0 then say 'This is not a CD-ROM disc.'
  291.   else say 'This is a CD-ROM disc.'
  292.  
  293. /* LSN TOC */
  294. say
  295. say '-- LSN TOC test --'
  296. say
  297.  
  298. TOCLSN lTOC 100 0                                /* Read TOC with summary */
  299.  
  300. say                                                        /* Display TOC */
  301. say 'Summary:  FirstTrack= ' lTOC.Summary.FirstTrack
  302. say '          LastTrack=  ' lTOC.Summary.LastTrack
  303. say '          LeadOut=    ' lTOC.Summary.LeadOut
  304. say
  305.  
  306. say 'Track No.  Track Pos.  Control Byte'
  307. say '---------  ----------  ------------'
  308.  
  309. do trck = 1 to lTOC.Summary.LastTrack
  310.   say center(lTOC.trck.Track,9) right(lTOC.trck.Position,9) right(lTOC.trck.CtlAdr,9)
  311.   master.trck.Track = lTOC.trck.Track
  312.   master.trck.Position = lTOC.trck.Position
  313.   mAster.trck.CtlAdr = lTOC.trck.CtlAdr
  314. end
  315.  
  316. /* MSF TOC */
  317. say
  318. say
  319. say '-- MSF TOC test --'
  320. say
  321.  
  322. TOCMSF mTOC 100 0                                /* Read TOC with summary */
  323.  
  324. msfEOD = toMSFform(mTOC.Summary.LeadOut.Minute, mTOC.Summary.LeadOut.Second, mTOC.Summary.LeadOut.Frame)
  325.  
  326. say                                                        /* Display TOC */
  327. say 'Summary:  FirstTrack= ' mTOC.Summary.FirstTrack
  328. say '          LastTrack=  ' mTOC.Summary.LastTrack
  329. say '          LeadOut=    ' msfEOD
  330. say
  331.  
  332. say 'Track No.  Track Pos.  Control Byte'
  333. say '---------  ----------  ------------'
  334.  
  335. do trck = 1 to mTOC.Summary.LastTrack
  336.   potion = toMSFform(mTOC.trck.Position.Minute, mTOC.trck.Position.Second, mTOC.trck.Position.Frame)
  337.   mCopy.trck.Track = mTOC.trck.Track
  338.   mCopy.trck.Position = potion
  339.   mCopy.trck.CtlAdr = mTOC.trck.CtlAdr
  340.   say center(mTOC.trck.Track,9) center(potion,12) center(mTOC.trck.CtlAdr,12)
  341. end
  342.  
  343. /**************************************************************************/
  344.  
  345. /* LSN and MSF Comparisons */
  346.  
  347. say
  348. say
  349. say 'Differences between the LSN and the MSF specifications (LSN format):'
  350. say
  351.  
  352. say 'Track No.  LSN Track Pos.  MSF Track Pos.  LSN Ctrl Byte  MSF Ctrl Byte'
  353. say '---------  --------------  --------------  -------------  -------------'
  354. do trck = 1 to mTOC.Summary.LastTrack
  355.   mPos = msf2sec(mCopy.trck.Position) * 75
  356.   mPos = trunc(mPos - (msf2sec(mCopy.1.Position) * 75))
  357.   lPos = master.trck.Position
  358.   say center(trck,9) right(lPos,11) right(mPos,15) right(master.trck.CtlAdr,12) right(mCopy.trck.CtlAdr,14)
  359. end
  360.  
  361.  
  362. /* Comparison between Master TOC and individual TOC */
  363.  
  364. say
  365. say
  366. say '-- Summary Verification --'
  367. say
  368. do trck = 1 to 99 while substr(master.trck.Track,1,1) ~= 'M'
  369. end
  370. tracks = trck - 1
  371. if tracks ~= 1 then say 'There are' tracks 'tracks on this disk.'
  372.   else say 'There is 1 track on this disk.'
  373. if tracks = lTOC.Summary.LastTrack then say 'This agrees with the summary data.'
  374.   else say 'The summary and the actual track information are in conflict!'
  375. say
  376.  
  377. end;
  378.  
  379. QUIT        /* Quits from CDTEST */
  380. exit        /* Exit from script */
  381.  
  382. /***** FUNCTIONS **********************************************************/
  383.  
  384. diskSwap: procedure                   /* Provoke a diskswap from the user */
  385.   MOTOR OFF
  386.   pull answ
  387. /* if answ = 'ON' then MOTOR ON */
  388.   INFO thisDisk
  389.   if thisDisk.Spin = 0 then do;
  390.     call delay(4.5)
  391.     INFO thisDisk
  392.   end
  393.   do while thisDisk.Spin = 0
  394.     say 'Disk must be spinning to continue.'
  395.     say 'Please engage the disc player. (CR to cont.)'
  396.     pull answ
  397.  /* if answ = 'ON' then MOTOR ON */
  398.     INFO thisDisk
  399.     if thisDisk.Spin = 0 then do;
  400.       call delay(4.5)
  401.       INFO thisDisk
  402.     end
  403.     say
  404.   end;
  405. return
  406.  
  407. rSpeed: procedure                           /* Outputs current read speed */
  408.   INFO thisDisk
  409.   kps = thisDisk.ReadSpeed * 2048
  410.   say 'Read speed is' thisDisk.ReadSpeed 'frames per second ('kps' KB/sec.)'
  411.   say
  412. return
  413.  
  414. dInfo: procedure                        /* Outputs disc/drive information */
  415.   call delay(2)
  416.   INFO thisDisk
  417.   say 'Play speed      ' thisDisk.PlaySpeed
  418.   say 'Read speed      ' thisDisk.ReadSpeed
  419.   say 'CD-XL read speed' thisDisk.ReadXLSpeed
  420.   say 'Sector size     ' thisDisk.SectorSize 'bytes'
  421.   say 'Max drive speed ' thisDisk.MaxSpeed
  422.   if thisDisk.Spin = 0 then say 'Disk is not spinning.'
  423.     else say 'Disk is spinning.'
  424.   if thisDisk.CDROM = 0 then say 'This is not a CD-ROM disc.'
  425.     else say 'This is a CD-ROM disc.'
  426.   say
  427.   call delay(1)
  428. return
  429.  
  430. delay: procedure                 /* Pauses for a specified no. of seconds */
  431. arg timeindex
  432. /* say 'Beginning' timeindex 'second delay. <data.cd>' */
  433.   call time 'R'
  434.   do until time('E') >= timeindex
  435.   end
  436. return
  437.  
  438. formt:                                         /* Formats 2-digit numbers */
  439. arg oldnum
  440. if oldnum <= 9 then newnum = '0'||oldnum
  441.   else newnum = oldnum
  442. return newnum
  443.  
  444. msf2sec:                                /* Converts MSF format to seconds */
  445. arg msfForm
  446.   min = substr(msfForm,1,2)
  447.   sec = substr(msfForm,4,2)
  448.   frm = substr(msfForm,7,2)
  449.   totsec = (min * 60) + sec + frm / 75
  450. return totsec
  451.  
  452. toMSFform:                       /* Converts mm, ss, and ff into mm:ss:ff */
  453. arg min, sec, frm
  454.   combo = formt(min) || ':' || formt(sec) || ':' || formt(frm)
  455. return combo
  456.  
  457. trunc:            /* Deletes decimal point and numbers to the right of it */
  458. arg oldnum
  459.   key = index(oldnum||'.', '.')
  460.   newnum = delstr(oldnum, key)
  461. return newnum
  462.